package com.zhiyou.app.pojo.enums;


import java.util.Arrays;

/**
 * @Description 订单类型枚举
 * @Author : bind
 * @Date : 2022-06-14 14:41
 */
public enum TaskStatusEnum {
    CREATE("create", "创建"),
    PROCESSING("processing", "执行中"),
    ERROR("error", "执行失败"),
    COMPLETE("complete", "执行完成"),
    ;

    public final String code;
    public final String name;

    TaskStatusEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static boolean contains(String s) {
        return Arrays.stream(TaskStatusEnum.values()).map(TaskStatusEnum::toString).anyMatch(s::equals);
    }

    @Override
    public String toString() {
        return String.valueOf(this.code);
    }

    public static TaskStatusEnum parse(String code) {
        return Arrays.stream(TaskStatusEnum.values()).filter(s -> s.code.equals(code)).findFirst().orElse(null);
    }
}
